package conceptmaniax.hotelapp.adapters;

public class Detail implements Comparable<Detail> {
	
	private int id;
	private String name;
	private String description;
	private String details;
	private String location;
	private String address;
	private String supervisor;
	private String phone;
	private String website;
	private String photo;
	
	// derivative fields
	private double distance;
	private String distanceStr;
	
	public Detail() {
		super();
	}

	public Detail(final int id, final String name, final double distance, final String distanceStr, 
			final String description, final String location, final String photo) {
		this.id = id;
		this.name = name;
		this.distance = distance;
		this.distanceStr = distanceStr;
		this.description = description;
		this.location = location;
		this.photo = photo;
	}

	public int getId() {
		return id;
	}

	public void setId(final int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(final String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(final String description) {
		this.description = description;
	}

	public String getDetails() {
		return details;
	}

	public void setDetails(final String details) {
		this.details = details;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(final String location) {
		this.location = location;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(final String address) {
		this.address = address;
	}

	public String getSupervisor() {
		return supervisor;
	}

	public void setSupervisor(final String supervisor) {
		this.supervisor = supervisor;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(final String phone) {
		this.phone = phone;
	}

	public String getWebsite() {
		return website;
	}

	public void setWebsite(final String website) {
		this.website = website;
	}

	public double getDistance() {
		return distance;
	}

	public void setDistance(final double distance) {
		this.distance = distance;
	}

	public String getDistanceStr() {
		return distanceStr;
	}

	public void setDistanceStr(final String distanceStr) {
		this.distanceStr = distanceStr;
	}

	public String getPhoto() {
		return photo;
	}

	public void setPhoto(String photo) {
		this.photo = photo;
	}

	@Override
	public String toString() {
		return "Detail [id=" + id + ", name=" + name + ", description="
				+ description + ", details=" + details + ", location="
				+ location + ", address=" + address + ", supervisor="
				+ supervisor + ", phone=" + phone + ", website=" + website
				+ ", photo=" + photo + ", distance=" + distance
				+ ", distanceStr=" + distanceStr + "]";
	}

	@Override
	public int compareTo(final Detail obj) {
		if (this == obj) {
			return 0;
		}

		if (!(obj instanceof Detail)) {
			throw new ClassCastException("Invalid object");
		}

		return (this.getDistance() > ((Detail) obj).getDistance())?1:-1;
	}
	
	@Override
	public boolean equals(final Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof Detail)) {
			return false;
		}

		return (this.distance == ((Detail) obj).distance);
	}

	@Override
	public int hashCode() {
		return 31 * 7 * (int)this.distance;
	}
}